#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/2/5 22:14
# @Author  : Ramsey
# @Site    : zh
# @File    : project.py
# @Software: PyCharm
from importlib import import_module


def load_class(_path):
    if not isinstance(_path, str):
        if callable(_path):
            return _path
        else:
            raise TypeError("_path must be str or callable")

    module, name = _path.rsplit(".", 1)
    mod = import_module(module)
    try:
        cls = getattr(mod, name)
    except AttributeError:
        raise ImportError(f"{_path} not found")
    else:
        return cls


if __name__ == "__main__":
    pass
